package com.ztatic.fightmode.control;

import com.ztatic.fightmode.views.IntroScreen;
import com.ztatic.fightmode.views.LogoScreen;
import com.ztatic.fightmode.views.MainmenuScreen;
import com.ztatic.fightmode.views.Screen;

import android.app.Activity;
import android.view.View;

public class ScreenHandler {
	private Activity _currentContext;
	public static ScreenHandler g_Handler;
	
	private View _activeScreen;
	private View _nextScreen = null;
	
	public ScreenHandler(Activity context)
	{
		_currentContext = context;
	}
	
	public void init()
	{
		if(g_Handler == null)
			g_Handler = this;
	}
	
	public void requestScreenChange(Screens s)
	{
		if(s == Screens.LOGO)
		{
			_nextScreen = new LogoScreen(_currentContext);
		} else if(s == Screens.INTRO)
		{
			_nextScreen = new IntroScreen(_currentContext);
		} else if(s == Screens.MAINMENU)
		{
			_nextScreen = new MainmenuScreen(_currentContext);
		} else return;
		
		//_currentContext.setContentView(_nextScreen);
		
		_currentContext.runOnUiThread(new Runnable()
		{
			public void run()
			{
				_currentContext.setContentView(_nextScreen);
			}
		});
	}
	
	public void updateScreen()
	{
		if(_nextScreen == null)
			return;
		
		_activeScreen = _nextScreen;
		_nextScreen = null;
		

	}
	
	public void registerUiThread(Runnable thread)
	{
		;
	}
	
	public static enum Screens
	{
		LOGO,
		INTRO,
		MAINMENU
	}
}
